package com.software.customiocannotation;

import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.software.ioc_annotation_lib.annation.Click;
import com.software.ioc_annotation_lib.InjectTool;
import com.software.ioc_annotation_lib.annation.BindView;
import com.software.ioc_annotation_lib.annation.ContentView;
import com.software.ioc_annotation_lib.annation_common.OnClickCommon;
import com.software.ioc_annotation_lib.annation_common.OnClickLongCommon;

//gradle 8.0之后只能为常量，这里用字符串模拟
//注解 绑定布局
@ContentView("activity_main")
public class MainActivity extends AppCompatActivity {
    @BindView("bt_test1")
    private Button btn1;// 注解绑定的控件

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        InjectTool.inject(this);

        Toast.makeText(this, btn1.getText().toString(), Toast.LENGTH_SHORT).show();
    }

//    @Click("bt_test1")
//    private void show() {
//        Toast.makeText(this, "show is run", Toast.LENGTH_SHORT).show();
//    }

    @OnClickCommon("bt_test1")
    private boolean showClick(){
        Toast.makeText(this, "点击绑定", Toast.LENGTH_SHORT).show();
        return false;
    }

    @OnClickLongCommon("bt_test1")
    private boolean showLong() {
        Toast.makeText(this, "长按绑定", Toast.LENGTH_SHORT).show();
        return false;//必须返回，否则会空指针异常
    }
}